package edu.sctu.practice.class01.zhoumengxue.assign.assign08.assign08_02;
import java.io.*;
import java.net.*;

/**
 * Created by ASUS on 2015/12/24.
 */
public class Serv {

    public static void main(String args[]) {
        ServerSocket server = null;
        ServerThread thread;
        Socket you = null;
        while (true) {
            try {
                server = new ServerSocket(4331);//创建在端口4331上负责监听的 ServerSocket对象
            } catch (IOException e1) {
                System.out.println("正在监听");
            }
            try {
                you = server.accept(); // server返回和客户端相连接的Socket对象
                System.out.println("客户的地址:" + you.getInetAddress());
            } catch (IOException e) {
                System.out.println("正在等待客户");
            }
            if (you != null) {
                new ServerThread(you).start();
            } else {
                continue;
            }
        }
    }
}

